转载:按照预期初始化布局--layout inflation as intended
代码中写“ View PrcItm = inflater.inflate(R.layout. unitlayout , null ); //添加科室元件 ”会引起警告:“Avoid passing null as the view root (needed to resolve layout parameters on the inflated layout's root element)”。这种情况下,妳应当使用有三个参数的“View android.view.LayoutInflater.inflate(int resource, ViewGroup root, boolean attachToRoot)”方法,并且传入正确的root参数,将attachToRoot设置为false,就可以解决这个警告了。
https://zybuluo.com/flyouting/note/17812
亮点:
如果我们换一种实现方式:
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = inflate(R.layout.item_row, parent, false);
}
return convertView;
}
我们就会得到我们希望的结果:
鲍蕾
Your opinionsHxLauncher: Launch Android applications by voice commands